﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace lcps.Web.userinfo
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
				{
					int ID=(Convert.ToInt32(Request.Params["id"]));
					ShowInfo(ID);
				}
			}
		}
			
	private void ShowInfo(int ID)
	{
		lcps.BLL.userinfo bll=new lcps.BLL.userinfo();
		lcps.Model.userinfo model=bll.GetModel(ID);
		this.lblID.Text=model.ID.ToString();
		this.txtusername.Text=model.username;
		this.txtuserpwd.Text=model.userpwd;
		this.txtusertruename.Text=model.usertruename;
		this.txtuserrank.Text=model.userrank;

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(this.txtusername.Text.Trim().Length==0)
			{
				strErr+="username不能为空！\\n";	
			}
			if(this.txtuserpwd.Text.Trim().Length==0)
			{
				strErr+="userpwd不能为空！\\n";	
			}
			if(this.txtusertruename.Text.Trim().Length==0)
			{
				strErr+="usertruename不能为空！\\n";	
			}
			if(this.txtuserrank.Text.Trim().Length==0)
			{
				strErr+="userrank不能为空！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			int ID=int.Parse(this.lblID.Text);
			string username=this.txtusername.Text;
			string userpwd=this.txtuserpwd.Text;
			string usertruename=this.txtusertruename.Text;
			string userrank=this.txtuserrank.Text;


			lcps.Model.userinfo model=new lcps.Model.userinfo();
			model.ID=ID;
			model.username=username;
			model.userpwd=userpwd;
			model.usertruename=usertruename;
			model.userrank=userrank;

			lcps.BLL.userinfo bll=new lcps.BLL.userinfo();
			bll.Update(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","list.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
